<%@ page language="java"
    import="com.gorge4j.user.*,com.gorge4j.user.constant.*,com.gorge4j.user.dto.*,com.gorge4j.user.vo.*,java.util.*"
    contentType="text/html; charset=utf-8" pageEncoding="utf-8"
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<!-- 在JSP页面上引入其它类，也就是引入Java Bean -->
<jsp:useBean id="passwordDTO" class="com.gorge4j.user.dto.ModifyDTO" scope="page">
    <jsp:setProperty name="passwordDTO" property="*" />
</jsp:useBean>
<jsp:useBean id="businessOperationBean" class="com.gorge4j.user.BusinessOperationBean" scope="page" />
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>密码校验</title>
</head>
<body>
    <%
        // 用户需登录后才能访问此页面
        UserSessionDTO userSession = (UserSessionDTO) session.getAttribute("userSession");
        try {
            if (userSession == null || !userSession.getIsLogin()) {
                response.sendRedirect("login.jsp");
            }
        } catch (Exception e) {
            response.sendRedirect("login.jsp");
        }
        // 给密码修改值对象补足部分参数
        passwordDTO.setName(userSession.getName());
        passwordDTO.setType(userSession.getType());
        // 把参数赋值给后端业务处理类
        businessOperationBean.setPasswordDTO(passwordDTO);
        // 调用后端的的登录逻辑，并返回当前登录的用户信息
        ResponseVO respVO = businessOperationBean.modify();
        // 如果返回的当前登录用户信息有值，则展示当前用户的信息
        if (respVO != null && !respVO.getCode().equals(ResponseConstant.SUCCESS)) {
            out.println(respVO.getMessage());
        } else {
    %>
    <jsp:forward page="login.jsp" />
    <%
        }
    %>
</body>
</html>